<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录显示关闭</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        a {
            text-decoration: none;
            color: #000;
        }

        .push {
            width: 100px;
            height: 50px;
            margin: 0 auto;
            font-size: 18px;
            text-align: center;
            line-height: 50px;
            z-index: 9999;
        }

        .login {
            position: fixed;
            top: 50%;
            left: 50%;
            width: 400px;
            height: 300px;
            margin: 0 auto;
            text-align: center;
            background-color: #fff;
            transform: translate(-50%, -50%);
        }

        .close {
            position: absolute;
            width: 30px;
            height: 30px;
            background-color: #fff;
            top: 0;
            right: 0;
            border-radius: 30px;
            font-size: 5px;
            transform: translate(50%, -50%);
            text-align: center;
            line-height: 30px;
        }

        label {
            display: inline-block;
            width: 50px;
        }

        input {
            margin-bottom: 20px;
            border: 1px solid rgba(0, 0, 0, .3);
            height: 25px;
        }

        .move {
            width: 80px;
            height: 20px;
            margin: 30px auto;
            cursor: move;
        }

        .mask {
            display: none;
            position: fixed;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, .3);
            top: 0;
            left: 0;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="push"><a href="javascript:;" id="l">点击登录</a></div>
    <div class="mask">
        <div class="login">
            <div class="close"><a href="javascript:;" id="c">关闭</a></div>
            <div class="move">会员登录</div>
            <div>
                <label for="t">用户名</label>
                <input type="text" id="t" placeholder="请输入用户名">
            </div>
            <div>
                <label for="p">密码</label>
                <input type="password" id="p" placeholder="请输入密码">
            </div>
            <button class="btn">登录会员</button>
        </div>
    </div>
    <script>
        var log = document.querySelector('#l');
        var mask = document.querySelector('.mask');
        var close = document.querySelector('#c');
        var login = document.querySelector('.login');
        var move = document.querySelector('.move');
        log.addEventListener('click', function () {
            mask.style.display = 'block';
        })
        close.addEventListener('click', function () {
            mask.style.display = 'none';
        })
        move.addEventListener('mousedown', function (e) {
            var x = e.pageX - login.offsetLeft;
            var y = e.pageY - login.offsetTop;
            document.addEventListener('mousemove', fn)
            function fn(e) {
                login.style.top = e.pageY - y + 'px';
                login.style.left = e.pageX - x + 'px';
            }
            document.addEventListener('mouseup', function () {
                document.removeEventListener('mousemove', fn);
            })
        })
    </script>
</body>

</html>